|
|
|
|
|
|
|
Dim nResult As Integer
'
nResult = MsgBox("Write changes to Column", vbInformation + vbYesNo,
_ "DBGrid.BeforeColUpdate")
If nResult = vbNo Then
Cancel = False ' cancel change & get old value
End If
End Sub |
|
|
|
|
|
|
|
|
Now add the code that tells the user the column has been updated as requested. Place the following code in the DBGrid1.AfterColUpdate event: |
|
|
|
|
|
|
|
|
Private Sub DBGrid1_AfterColUpdate(ByVal ColIndex As Integer)
'
' tell user
'
MsgBox "Column has been updated", vbInformation, "DBGrid.AfterColUpdate"
End Sub |
|
|
|
|
|
|
|
|
Save and run the project. Now, each time you attempt to alter a column, you are asked to confirm the column update. (See Figure 12.16.) |
|
|
|
|
|
|
|
|
Figure 12.16.
Updating a grid column. |
|
|
|
|
|
|
|
|
You can also see a message when you leave the column telling you that the data has been changed. |
|
|
|
|
|
|
|
|
Creating the dbFind Custom Control |
|
|
|
|
|
|
|
|
A very common use of the data-bound list controls is the creation of a dialog box that lists all the primary keys in a table. This dialog lets users select an item from the list and then displays the complete data record that is associated with the primary key. In this section, you'll learn how to build a custom control that does just that. Once this control is completed, you'll be able to place it on any Visual Basic form and add an instant ''Find" dialog to all your Visual Basic forms. |
|
|
|
|
|
|
|
|
This custom control project has two main parts. The first is the find button. This is the object that users place on their forms. By pressing the button, users see a dialog box containing a list of all the records in the table. The dialog box itself is the second part of the custom control. This dialog contains a data-bound list box, a data control, and two command buttons. |
|
|
|
|
|